﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using QLTVNEW.Properties;
using System.Data.Linq;
using System.Windows.Forms;

namespace QLTVNEW
{
    public partial class frmMuonSach : DevComponents.DotNetBar.Office2007Form
    {
        public frmMuonSach()
        {
            InitializeComponent();

            txtMuon.Text = date.ToString("dd/MM/yyyy");
            txtTra.Text = date.AddDays(7).ToString("dd/MM/yyyy");
        }
        #region 'LT'
            DateTime date = DateTime.Now;
        #endregion
        private void frmMuonSach_Load(object sender, EventArgs e)
        {

        }

        private void txtMuon_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtMuon.MaskFull)
            {
                try
                {
                    DateTime.ParseExact(txtMuon.Text, "dd/MM/yyyy", null);
                }
                catch
                {
                    MessageBox.Show("Ngày Không Hợp Lệ","Thông Báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    txtMuon.ResetText();
                }
            }
        }

        private void txtTra_KeyUp(object sender, KeyEventArgs e)
        {
            if (txtTra.MaskFull)
            {
                try
                {
                    DateTime.ParseExact(txtTra.Text, "dd/MM/yyyy", null);
                }
                catch 
                {
                    MessageBox.Show("Ngày Không Hợp Lệ","Thông Báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    txtTra.ResetText();
                }
            }
        }

        private void btnclear_Click(object sender, EventArgs e)
        {
            foreach (Control ctr in groupBox1.Controls)
            {
                if (ctr is ComboBox || ctr is TextBox)
                {
                    ctr.Text = "";
                    txtMuon.Text = date.ToString("dd/MM/yyyy");
                    txtTra.Text = date.AddDays(7).ToString("dd/MM/yyyy");
                }
            }
        }

        private void frmMuonSach_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.AutoValidate = AutoValidate.Disable;
        }
    }
}
